import BuffUtil from '@/BuffUtil';
import Buff from '@/Buff';
import ArrayUtil from '@/ArrayUtil';
import ItemUtil from '@/ItemUtil';
import BaseUtil from '@/BaseUtil';
import SelectUtil from '@/SelectUtil';
import SelectCommon from 'code/Core/Common/SelectCommon';
export default class Item_滂臭的咸鱼 {
    static id = 'C00I';
    static itemId = FourCC('C00I');
    static 名称: string = '滂臭的咸鱼';
    static 描述: string = '好臭啊';
    static 图标: string = 'assets\\item\\INV_Fishing_82_ViperFish.blp';
    static buffId: string = 'buff_item_chouxuanyu';
    static buffType: AppBuffType = {
        id: 'buff_item_chouxuanyu',
        name: Item_滂臭的咸鱼.名称,
        ubertip: Item_滂臭的咸鱼.描述,
        art: Item_滂臭的咸鱼.图标,
        targetArt: 'Units\\Undead\\PlagueCloud\\PlagueCloudtarget.mdl',
        targetAttach: 'origin',
        dur: 2,
        interval: 1,
        onInterval: Item_滂臭的咸鱼.buffInterval,
        isDebuff: true,
        class: '光环',
    };
    static providers: unit[] = [];
    static buffInterval(buff: Buff) {
        DamageSystemInstance.applyPoisionDamage(buff.getParent(), buff.getCaster(), 150, null, true);
    }
    constructor() {
        BuffUtil.registerBuffType(Item_滂臭的咸鱼.buffType);
        se.onUnitPickupItem(Item_滂臭的咸鱼.pickItem);
        se.onUnitDropItem(Item_滂臭的咸鱼.dropItem);
        se.onUnitSellItem(Item_滂臭的咸鱼.dropItem);
        se.onUnitPawnItem(Item_滂臭的咸鱼.dropItem);
        BaseUtil.onTimer(1, Item_滂臭的咸鱼.timerEffect);
    }
    static timerEffect() {
        for (let p of Item_滂臭的咸鱼.providers) {
            let es = [].concat(SelectCommon.getAllyUnitInRange(p, 350), SelectUtil.getEnemyUnitsInRange(p, 350));
            for (let e of es) {
                BuffUtil.addBuff(e, Item_滂臭的咸鱼.buffId, p);
            }
        }
        return true;
    }
    static dropItem() {
        let item = GetManipulatedItem();
        if (GetItemTypeId(item) != Item_滂臭的咸鱼.itemId) return;
        let u = GetTriggerUnit();
        BaseUtil.runLater(0.1, () => {
            let count = ItemUtil.getItemCountOfTypeFromUnit(u, Item_滂臭的咸鱼.id);
            if (count == 0) ArrayUtil.removeElement(Item_滂臭的咸鱼.providers, u);
        });
    }
    static pickItem() {
        let u = GetTriggerUnit();
        let item = GetManipulatedItem();
        if (GetItemTypeId(item) != Item_滂臭的咸鱼.itemId) return;
        if (Item_滂臭的咸鱼.providers.includes(u)) return;
        Item_滂臭的咸鱼.providers.push(u);
    }
}
